home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.src.lzh / relay / amiga.c < prev    next >
C/C++ Source or Header  |  1989-12-29  |  2KB  |  150 lines

  1. /*
  2.  *    Compatibility routines needed by relaynews.
  3.  *    The sleep() routine is here 'cuz in the UUPC code
  4.  *        it would generate "symbol redefined" if put in
  5.  *        the libcnews library.
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <libraries/dos.h>
  10. #include "news.h"
  11.  
  12. #ifdef AZTEC_C
  13. #  include <functions.h>
  14. #else
  15. #  include <proto/exec.h>
  16. #endif
  17.  
  18. void sleep(sec)
  19. unsigned long sec;
  20. {
  21.     Delay( TICKS_PER_SECOND * sec );
  22. }
  23.  
  24. int fork()
  25. {
  26.     return( -1 );
  27. }
  28.  
  29. int system(s)
  30. char *s;
  31. {
  32.     warning("attempting system() call: '%s'", s);
  33.     return( -1 );
  34. }
  35.  
  36. FILE *popen(name, mode)
  37. char *name, *mode;
  38. {
  39.     if (index(mode, '+'))
  40.         return( fopen(name, mode) );
  41.     else {
  42.         char buf[16];
  43.  
  44.         strcpy(buf, mode);
  45.         strcat(buf, "+");
  46.         return( fopen(name, buf) );
  47.     }
  48. }
  49.  
  50. int pclose(fp)
  51. FILE *fp;
  52. {
  53.     return( fclose(fp) );
  54. }
  55.  
  56. static void GetCurrentPath( path )
  57. register char *path;
  58. {
  59.     char    s1[ 108 ];
  60.     char    *name;
  61.     struct FileInfoBlock fib;
  62.     register struct FileLock *locka, *lockb = 0;
  63.  
  64.     locka = Lock("", ACCESS_READ );
  65.     *path = s1[0] = '\0';
  66.  
  67.     while (locka != NULL) {
  68.         Examine( locka, &fib );
  69.         name = fib.fib_FileName;
  70.         if ( *name == '\0' )
  71.             strcpy( path, "RAM" ); /* Patch for Ram disk bug */
  72.         else
  73.             strcpy( path, name );
  74.         lockb = ParentDir( locka );
  75.         UnLock( locka );
  76.  
  77.         if (lockb == NULL)
  78.             strcat( path, ":");
  79.         else if (s1[0] != '\0')
  80.             strcat( path, "/");
  81.         strcat( path, s1 );
  82.         strcpy( s1, path );
  83.         locka = lockb;
  84.     }
  85. }
  86.  
  87. /*--------------------------------------------------------------*/
  88. /*    getcwd: return the path name of the current directory    */
  89. /*--------------------------------------------------------------*/
  90.  
  91. char *getcwd( path, size )
  92. char *path;
  93. int size;
  94. {
  95.     if (path == (char *)NULL) {
  96.         if ((path = malloc(108)) == NULL)
  97.             return NULL;
  98.     }
  99.     GetCurrentPath( path );
  100.     return path;
  101. }
  102.  
  103. int    chdir(path)
  104. char *path;
  105. {
  106.     register struct FileLock *lock, *oldLock;
  107.  
  108.     lock = Lock(path, ACCESS_READ);
  109.     if (!lock)
  110.         return (int) IoErr();
  111.     oldLock = CurrentDir(lock);
  112.     if (oldLock)
  113.         UnLock(oldLock);
  114.     return 0;
  115. }
  116.  
  117. int mkdir( name )
  118. char *name;
  119. {
  120.     extern int errno;
  121.     register struct FileLock *lock;
  122.  
  123.     lock = CreateDir( name );
  124.     if ( !lock )
  125.        return errno;
  126.     UnLock( lock );
  127.     return 0;
  128. }
  129.  
  130. #if 0
  131. /*
  132.  *    If using Manx, should link with `heapmem.o'
  133.  */
  134. char *realloc(ptr, size)
  135. char *ptr;
  136. unsigned size;
  137. {
  138.     register char *tmp;
  139.     register unsigned len;
  140.  
  141.     tmp = (char *) malloc( size );
  142.     if (ptr) {
  143.         len = * (long *) (ptr-4);
  144.         movmem(ptr, tmp, (unsigned) min(len, size));
  145.         free( ptr );
  146.     }
  147.     return( tmp );
  148. }
  149. #endif
  150.